package com.java.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.java.dao.ApplyMapper;
import com.java.dao.StatusMapper;
import com.java.model.Apply;
import com.java.model.Result;
import com.java.model.Status;
import com.java.service.LaunchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LaunchServiceImpl implements LaunchService {

    @Autowired
    private ApplyMapper applyMapper;

    @Autowired
    private StatusMapper statusMapper;

    @Override
    public PageInfo<Apply> applyList(Apply apply) {
        PageHelper.startPage(apply.getPageNum(), apply.getPageSize());
        List<Apply> list = applyMapper.applyList(apply);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<Apply> forwardList(Apply apply) {
        PageHelper.startPage(apply.getPageNum(), apply.getPageSize());
        List<Apply> list = applyMapper.forwardList(apply);
        return new PageInfo<>(list);
    }

    @Override
    public Result yes(Apply apply) {
        applyMapper.yes(apply);
        return Result.success();

    }

    @Override
    public Result yes2(Apply apply) {
        applyMapper.yes(apply);
        return Result.success();

    }

    @Override
    public List<Status> state() {
        return statusMapper.state();
    }

    @Override
    public PageInfo<Apply> adminList(Apply apply) {
        PageHelper.startPage(apply.getPageNum(), apply.getPageSize());
        List<Apply> list = applyMapper.adminList(apply);
        return new PageInfo<>(list);
    }

}
